<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>教师后台-不学也通</title>
    <style>
        .container {
            min-height: 100vh;
        }

        .container .leftmenu {
            min-height: 100vh;
            background-color: #fff;
        }

        .link-secondary {
            text-decoration: none;
        }

        .link-secondary:hover {
            color: #0d6efd !important;
        }

        .position-relative .position-absolute {
            display: none;
        }

        .card:hover .position-absolute {
            display: block;
        }
    </style>
</head>

<body>
    <!-- container是bootstrap的居中窄的显示方案 -->
    <div class="container bg-body-secondary">
        <div class="row">
            <div class="col-md-2 leftmenu" id="leftmenu"></div>
            <div class="col-md-9 kc ms-3">
                <div class="row mt-3">
                    <!-- row似乎不能同时使用flex布局 -->
                    <ul class="nav nav-tabs">
                        <li class="nav-item">
                            <a class="nav-link nav-tab active" aria-current="page" href="#">我教的课程</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link nav-tab" href="#">我学的课程</a>
                        </li>
                        <li class="nav-item">
                            <select class="form-select" aria-label="select example">
                                <option selected value="-1">请选择学期</option>
                                <option value="0">2022-2023第二学期</option>
                                <option value="1">2022-2023第一学期</option>
                                <option value="2">2021-2022第二学期</option>
                                <option value="3">2021-2022第一学期</option>
                            </select>
                        </li>
                        <li class="nav-item ms-5" style="position: relative;">
                            <input type="text" class="form-control rounded-pill" placeholder="请输入课程名">
                            <i class="bi bi-search" style="position: absolute;right: 1rem;top: 0.7rem;"></i>
                        </li>
                        <li class="nav-item ms-5">
                            <a class="nav-link link-success" href="#">
                                <i class="bi bi-plus-circle-fill"></i>
                                创建文件夹
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link link-success" href="./createcourse.html">
                                <i class="bi bi-plus-circle-fill"></i>
                                创建课程
                            </a>
                        </li>
                    </ul>
                </div>
                <div class="row ms-3" id="course">
                    <div class="card m-3" style="width: 18rem;">
                        <img src="../imgs/qd.jpg" width="262" height="180" class="card-img-top mt-2" alt="web前端">
                        <div class="card-body">
                            <h5 class="card-title">web前端开发基础</h5>
                            <h6 class="mt-1 text-muted">平顶山职业技术学校</h6>
                            <h6 class="mt-1 text-muted">课程号:mb-001</h6>
                            <h6 class="mt-1 text-muted">教师:尹双义</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>22级移动应用开发</div>
                                <div>17<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>

                    <div class="card m-3" style="width: 18rem;">
                        <img src="../imgs/js.webp" width="262" height="180" class="card-img-top mt-2" alt="web前端">
                        <div class="card-body">
                            <h5 class="card-title">JavaScript高级程序设计</h5>
                            <h6 class="mt-1 text-muted">平顶山职业技术学校</h6>
                            <h6 class="mt-1 text-muted">课程号:mb-002</h6>
                            <h6 class="mt-1 text-muted">教师:尹双义</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>22级移动应用开发</div>
                                <div>17<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>

                    <div class="card m-3" style="width: 18rem;">
                        <img src="../imgs/bootstrap.webp" width="262" height="180" class="card-img-top mt-2"
                            alt="web前端">
                        <div class="card-body">
                            <h5 class="card-title">bootstrap与移动应用开发</h5>
                            <h6 class="mt-1 text-muted">平顶山职业技术学校</h6>
                            <h6 class="mt-1 text-muted">课程号:mb-003</h6>
                            <h6 class="mt-1 text-muted">教师:尹双义</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>22级移动应用开发</div>
                                <div>17<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>

                    <div class="card m-3" style="width: 18rem;">
                        <img src="../imgs/jQuery.jpg" width="262" height="180" class="card-img-top mt-2" alt="web前端">
                        <div class="card-body">
                            <h5 class="card-title">jQuery</h5>
                            <h6 class="mt-1 text-muted">平顶山职业技术学校</h6>
                            <h6 class="mt-1 text-muted">课程号:mb-004</h6>
                            <h6 class="mt-1 text-muted">教师:尹双义</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>22级移动应用开发</div>
                                <div>17<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>

                    <div class="card m-3" style="width: 18rem;">
                        <img src="../imgs/css.png" width="262" height="180" class="card-img-top mt-2" alt="web前端">
                        <div class="card-body">
                            <h5 class="card-title">css</h5>
                            <h6 class="mt-1 text-muted">平顶山职业技术学校</h6>
                            <h6 class="mt-1 text-muted">课程号:mb-005</h6>
                            <h6 class="mt-1 text-muted">教师:尹双义</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>22级移动应用开发</div>
                                <div>17<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>

                    <div class="card m-3" style="width: 18rem;">
                        <img src="../imgs/html.webp" width="262" height="180" class="card-img-top mt-2" alt="web前端">
                        <div class="card-body">
                            <h5 class="card-title">html</h5>
                            <h6 class="mt-1 text-muted">平顶山职业技术学校</h6>
                            <h6 class="mt-1 text-muted">课程号:mb-006</h6>
                            <h6 class="mt-1 text-muted">教师:尹双义</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>22级移动应用开发</div>
                                <div>17<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>

                    <div class="d-grid gap-3 col-1 mx-auto position-absolute bottom-0 end-0 ">
                        <button class="btn btn-primary form-control rounded-pill text-bg-light p-3" type="button">
                            <i class="bi bi-volume-up-fill"></i>更新公告</button>
                        <button class="btn btn-primary form-control rounded-pill text-bg-light p-3" type="button">
                            <i class="bi bi-question-octagon-fill"></i>使用说明</button>
                        <button class="btn btn-primary form-control rounded-pill text-bg-light p-3" type="button">
                            <i class="bi bi-github"></i>在线客服</button>
                        <button class="btn btn-primary form-control rounded-pill text-bg-light p-3" type="button">
                            <i class="bi bi-arrow-up-circle-fill"></i>返回顶部</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    <script type="module" src="../js/main.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/common.js"></script>
    <script>
        $(document).ready(function () {
            //当用户点击class是nav-tab的标签给该标签（添加之前删除所有active类）添加active类
            $(".nav-tab").click(function (e) {
                //删除nav-tab所有active类
                $(".nav-tab").removeClass("active");
                //给点击的标签添加active类
                $(this).addClass("active")
            })
            $.get("https://unicloud.codecore.cn/ms/courseAll?teacher_id=645484f2819ce8deeea2a59b", {}, function (params) {
                if (params.errCode == 0) {
                    for (let i = 0; i < params.data.length; i++) {
                        const elem = params.data[i];
                        $("#courses").append($(`<div class="card mt-3 position-relative ms-3" style="width: 18rem;">
                                  <div class="position-absolute top-0 end-0" style="right: 0;">
                                  <button class="btn btn-info bian"data-id=${elem._id}>移动到</button>
                                  <button class="btn btn-info shan"data-id="${elem._id}">退课</button>
                              </div>
                              <img src="${elem.course_url}"  alt="主演">
                              <div class="card-body">
                                  <h5 class="card-title">${elem.course_name}</h5>
                                  <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                                  <h6 class="mt-1 text-muted">2023.01~2023.04</h6>    
                                  <h6 class="mt-1 text-muted">主演 ${elem.teacher_name}</h6>
                                  <h6 class="mt-1 text-muted d-flex justify-content-between">
                                      <div>${elem.grade_code} ${elem.course_department}</div>
                                      <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                                  </h6>
                              </div>
                          </div>`))
                    }
                }
            })
            $("#courses").delegate("button.shan", "click", function () {
                // $(this).data() 获取点击元素上data属性中存放的数据
                let data = $(this).data();// data数据格式是{id:"字符串"} 比较符合后端要求 可以直接传递
                $.post("http://unicloud.codecore.cn/ms/courseRemove", data, function (params) {
                    console.log(params);
                    if (params.errCode == 0) {
                        location.reload();
                    } else { alert("退课异常") }
                })
            });

            $("#courses").delegate("button.bian", "click", function () {
                let data = $(this).data();
                // 跳转到新的页面 并将要编辑的数据的ID编号带过去
                location.href = `./edit_course.html?id=${data.id}`
            })
        })
    </script>
</body>

</html>